Number Format: Flag Field

image\regex2_shg.gif

Samples (Flag term is in red): %1<%+12.3f(E1-10)>

     %1<%+012.3f(E1-10)>

 

The first optional field of the format specification is flags. A flag directive is a character that justifies output and prints signs, blanks, decimal points, and octal and hexadecimal prefixes. More than one flag directive may appear in a format specification.

Flag

Meaning

Default

+

Prefix the output value with a sign (+ or û) if the output value is of a signed type.

Sign appears only for negative signed values (û).

0

If width is prefixed with 0, zeros are added until the minimum width is reached. If 0 and û appear, the 0 is ignored. If 0 is specified with an integer format (i, u, x, X, o, d) the 0 is ignored.

No padding

blank (' ')

Prefix the output value with a blank if the output value is signed and positive; the blank is ignored if both the blank and + flags appear.

No blank

#

When used with the o, x, or X format, the # flag prefixes any nonzero output value with 0, 0x, or 0X, respectively.

No blank

 

When used with the e, E, or f format, the # flag forces the output value to contain a decimal point in all cases.

Decimal point appears only if digits follow it.

 

When used with the g or G format, the # flag forces the output value to contain a decimal point in all cases and prevents the truncation of trailing zeros.

Ignored when used with c, d, i, u, or s.

Decimal point appears only if digits follow it. Trailing zeros are truncated.